package com.workcell.workdata.xthings.jobhandler;

import cn.hutool.core.date.DateUtil;
import com.workcell.workdata.xthings.service.AutoReportService;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.Date;

import static cn.hutool.core.date.DatePattern.NORM_DATETIME_MINUTE_FORMATTER;

@Component
@RequiredArgsConstructor
public class AutoReportJobHandler {

	private final AutoReportService autoReportService;

	/**
	 * 带式过滤工站自动报工
	 */
	@XxlJob("autoReportBeltWorkStationJob")
	public void autoReportBeltWorkStationJob() {
		XxlJobHelper.log("开始执行定期发送指令任务");
		autoReportService.autoReportBeltWorkStation(DateUtil.parse(DateUtil.format(new Date(),NORM_DATETIME_MINUTE_FORMATTER),NORM_DATETIME_MINUTE_FORMATTER));
		XxlJobHelper.handleSuccess("定期发送指令任务执行完成");
	}

	/**
	 * 烘干窑工站自动报工
	 */
	@XxlJob("autoReportDryingKilnStation")
	public void autoReportDryingKilnStation() {
		XxlJobHelper.log("开始执行定期发送指令任务");
		autoReportService.autoReportDryingKilnStation(DateUtil.parse(DateUtil.format(new Date(),NORM_DATETIME_MINUTE_FORMATTER),NORM_DATETIME_MINUTE_FORMATTER));
		XxlJobHelper.handleSuccess("定期发送指令任务执行完成");
	}

	/**
	 * 冷冻工站自动报工
	 */
	@XxlJob("autoReportFrozenStation")
	public void autoReportFrozenStation() {
		XxlJobHelper.log("开始执行定期发送指令任务");
		autoReportService.autoReportFrozenStation(DateUtil.parse(DateUtil.format(new Date(),NORM_DATETIME_MINUTE_FORMATTER),NORM_DATETIME_MINUTE_FORMATTER));
		XxlJobHelper.handleSuccess("定期发送指令任务执行完成");
	}

	/**
	 *  混料工站自动报工
	 */
	@XxlJob("autoReportMixingStation")
	public void autoReportMixingStation() {
		XxlJobHelper.log("开始执行定期发送指令任务");
		autoReportService.autoReportMixingStation(DateUtil.parse(DateUtil.format(new Date(),NORM_DATETIME_MINUTE_FORMATTER),NORM_DATETIME_MINUTE_FORMATTER));
		XxlJobHelper.handleSuccess("定期发送指令任务执行完成");
	}

	/**
	 *  焙烧工站自动报工
	 */
	@XxlJob("autoReportRoastingStation")
	public void autoReportRoastingStation() {
		XxlJobHelper.log("开始执行定期发送指令任务");
		autoReportService.autoReportRoastingStation(DateUtil.parse(DateUtil.format(new Date(),NORM_DATETIME_MINUTE_FORMATTER),NORM_DATETIME_MINUTE_FORMATTER));
		XxlJobHelper.handleSuccess("定期发送指令任务执行完成");
	}


	/**
	 *  功率计工站自动报工
	 */
	@XxlJob("autoReportPowerMeterData")
	public void autoReportPowerMeterData() {
		XxlJobHelper.log("开始执行定期发送指令任务");
		autoReportService.autoReportPowerMeterData(DateUtil.parse(DateUtil.format(new Date(),NORM_DATETIME_MINUTE_FORMATTER),NORM_DATETIME_MINUTE_FORMATTER));
		XxlJobHelper.handleSuccess("定期发送指令任务执行完成");
	}


	/**
	 *  球磨工站自动报工
	 */
	@XxlJob("autoReportBallMillStation")
	public void autoReportBallMillStation() {
		XxlJobHelper.log("开始执行定期发送指令任务");
		autoReportService.autoReportBallMillStation(DateUtil.parse(DateUtil.format(new Date(),NORM_DATETIME_MINUTE_FORMATTER),NORM_DATETIME_MINUTE_FORMATTER));
		XxlJobHelper.handleSuccess("定期发送指令任务执行完成");
	}

	/**
	 *  更新智能工作站，焙烧工站自动报工
	 */
	@XxlJob("autoReportSmartRoastingStation")
	public void autoReportSmartRoastingStation() {
		XxlJobHelper.log("开始执行定期发送指令任务");
		autoReportService.autoReportSmartRoastingStation(DateUtil.parse(DateUtil.format(new Date(),NORM_DATETIME_MINUTE_FORMATTER),NORM_DATETIME_MINUTE_FORMATTER));
		XxlJobHelper.handleSuccess("定期发送指令任务执行完成");
	}



}
